//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101
//#include "stdafx.h"
#include "GaussChebyshevPolynomial.h"
using namespace Cephei::QL::Math::Integrals;
#include <gen/QL/Math/Integrals/GaussJacobiPolynomial.h>
#undef HANDLE
#undef ABSTRACT
#undef STRUCT
Cephei::QL::Math::Integrals::CGaussChebyshevPolynomial::CGaussChebyshevPolynomial () : CGaussJacobiPolynomial(CGaussChebyshevPolynomial::typeid)
{
    try
    {
#ifdef HANDLE
        _phGaussChebyshevPolynomial = NULL;
#endif
        _ppGaussChebyshevPolynomial = new boost::shared_ptr<QuantLib::GaussChebyshevPolynomial> (new QuantLib::GaussChebyshevPolynomial ( ));
        SetGaussJacobiPolynomial (boost::dynamic_pointer_cast<QuantLib::GaussJacobiPolynomial> (*_ppGaussChebyshevPolynomial));
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Math::Integrals::CGaussChebyshevPolynomial::CGaussChebyshevPolynomial (boost::shared_ptr<QuantLib::GaussChebyshevPolynomial>& childNative, Object^ owner) : CGaussJacobiPolynomial(CGaussChebyshevPolynomial::typeid)
{
#ifdef HANDLE
	_phGaussChebyshevPolynomial = NULL;
#endif
	_ppGaussChebyshevPolynomial = &childNative;
    _ppGaussJacobiPolynomial = new boost::shared_ptr<QuantLib::GaussJacobiPolynomial> (boost::dynamic_pointer_cast<QuantLib::GaussJacobiPolynomial> (*_ppGaussChebyshevPolynomial));
}
Cephei::QL::Math::Integrals::CGaussChebyshevPolynomial::CGaussChebyshevPolynomial (QuantLib::GaussChebyshevPolynomial& childNative, Object^ owner) : CGaussJacobiPolynomial(CGaussChebyshevPolynomial::typeid)
{
#ifdef HANDLE
	_phGaussChebyshevPolynomial = NULL;
#endif
	_ppGaussChebyshevPolynomial = new boost::shared_ptr<QuantLib::GaussChebyshevPolynomial> (&childNative);
    _ppGaussJacobiPolynomial = new boost::shared_ptr<QuantLib::GaussJacobiPolynomial> (boost::dynamic_pointer_cast<QuantLib::GaussJacobiPolynomial> (*_ppGaussChebyshevPolynomial));
    _GaussChebyshevPolynomialOwner = owner;
    _GaussJacobiPolynomialOwner = owner;
}

Cephei::QL::Math::Integrals::CGaussChebyshevPolynomial::CGaussChebyshevPolynomial (CGaussChebyshevPolynomial^ copy) : CGaussJacobiPolynomial(CGaussChebyshevPolynomial::typeid)
{
#ifdef HANDLE
	_phGaussChebyshevPolynomial = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppGaussChebyshevPolynomial = new boost::shared_ptr<QuantLib::GaussChebyshevPolynomial> (copy->GetShared());
        _ppGaussJacobiPolynomial = new boost::shared_ptr<QuantLib::GaussJacobiPolynomial> (boost::dynamic_pointer_cast<QuantLib::GaussJacobiPolynomial> (*_ppGaussChebyshevPolynomial));
    }
}
Cephei::QL::Math::Integrals::CGaussChebyshevPolynomial::CGaussChebyshevPolynomial (System::Type^ t) : CGaussJacobiPolynomial(CGaussChebyshevPolynomial::typeid)
{
#ifdef HANDLE
	_phGaussChebyshevPolynomial = NULL;
#endif
	if (!t->IsSubclassOf(CGaussChebyshevPolynomial::typeid))
		throw gcnew Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Math::Integrals::CGaussChebyshevPolynomial::CGaussChebyshevPolynomial (QuantLib::Handle<QuantLib::GaussChebyshevPolynomial>& childNative, Object^ owner)  : CGaussJacobiPolynomial(CGaussChebyshevPolynomial::typeid)
{
	_phGaussChebyshevPolynomial = &childNative;
	_ppGaussChebyshevPolynomial = &static_cast<boost::shared_ptr<QuantLib::GaussChebyshevPolynomial>>(childNative.currentLink());
    _ppGaussJacobiPolynomial = new boost::shared_ptr<QuantLib::GaussJacobiPolynomial> (boost::dynamic_pointer_cast<QuantLib::GaussJacobiPolynomial> (*_ppGaussChebyshevPolynomial));
    _GaussChebyshevPolynomialOwner = owner;
}
Cephei::QL::Math::Integrals::CGaussChebyshevPolynomial::CGaussChebyshevPolynomial (QuantLib::Handle<QuantLib::GaussChebyshevPolynomial> childNative)  : CGaussJacobiPolynomial(CGaussChebyshevPolynomial::typeid)
{
	_phGaussChebyshevPolynomial = &childNative;
	_ppGaussChebyshevPolynomial = &static_cast<boost::shared_ptr<QuantLib::GaussChebyshevPolynomial>>(childNative.currentLink());
    _ppGaussJacobiPolynomial = new boost::shared_ptr<QuantLib::GaussJacobiPolynomial> (boost::dynamic_pointer_cast<QuantLib::GaussJacobiPolynomial> (*_ppGaussChebyshevPolynomial));
}
#endif
#ifdef STRUCT
Cephei::QL::Math::Integrals::CGaussChebyshevPolynomial::CGaussChebyshevPolynomial (QuantLib::GaussChebyshevPolynomial childNative)  : CGaussJacobiPolynomial(CGaussChebyshevPolynomial::typeid)
{
#ifdef HANDLE
	_phGaussChebyshevPolynomial = NULL;
#endif
	_ppGaussChebyshevPolynomial = new boost::shared_ptr<QuantLib::GaussChebyshevPolynomial> (new QuantLib::GaussChebyshevPolynomial (childNative));
    _ppGaussJacobiPolynomial = new boost::shared_ptr<QuantLib::GaussJacobiPolynomial> (boost::dynamic_pointer_cast<QuantLib::GaussJacobiPolynomial> (*_ppGaussChebyshevPolynomial));
}
#endif

Cephei::QL::Math::Integrals::CGaussChebyshevPolynomial::~CGaussChebyshevPolynomial ()
{
    if (_ppGaussChebyshevPolynomial != NULL)
    {
	    delete _ppGaussChebyshevPolynomial;
        _ppGaussChebyshevPolynomial = NULL;
    }
}
Cephei::QL::Math::Integrals::CGaussChebyshevPolynomial::!CGaussChebyshevPolynomial ()
{
    if (_ppGaussChebyshevPolynomial != NULL)
    {
	    delete _ppGaussChebyshevPolynomial;
    }
}
QuantLib::GaussChebyshevPolynomial& Cephei::QL::Math::Integrals::CGaussChebyshevPolynomial::GetReference ()
{
    if (_ppGaussChebyshevPolynomial == NULL) throw gcnew NativeNullException ();
	return **_ppGaussChebyshevPolynomial;
}
boost::shared_ptr<QuantLib::GaussChebyshevPolynomial>& Cephei::QL::Math::Integrals::CGaussChebyshevPolynomial::GetShared ()
{
    if (_ppGaussChebyshevPolynomial == NULL) throw gcnew NativeNullException ();
	return *_ppGaussChebyshevPolynomial;
}
QuantLib::GaussChebyshevPolynomial* Cephei::QL::Math::Integrals::CGaussChebyshevPolynomial::GetPointer ()
{
    if (_ppGaussChebyshevPolynomial == NULL) throw gcnew NativeNullException ();
	return &**_ppGaussChebyshevPolynomial;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::GaussChebyshevPolynomial>& Cephei::QL::Math::Integrals::CGaussChebyshevPolynomial::GetHandle ()
{
	if (_phGaussChebyshevPolynomial == NULL)
	{
		_phGaussChebyshevPolynomial = new Handle<QuantLib::GaussChebyshevPolynomial> (*_ppGaussChebyshevPolynomial);
	}
	return *_phGaussChebyshevPolynomial;
}
#endif
bool Cephei::QL::Math::Integrals::CGaussChebyshevPolynomial::HasNative () 
{
	return (_ppGaussChebyshevPolynomial != NULL);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

Cephei::QL::Math::Integrals::IGaussChebyshevPolynomial^ Cephei::QL::Math::Integrals::CGaussChebyshevPolynomial_Factory::Create ()
{
    return gcnew CGaussChebyshevPolynomial ();
}
